//
//  Wallet_WithdrawViewController.m
//  fxxiaoke
//
//  Created by 鞠超 on 2016/10/13.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Wallet_WithdrawViewController.h"

#import "Add_RechargeCardViewController.h"

@interface Wallet_WithdrawViewController ()

@end

@implementation Wallet_WithdrawViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = @"零钱提现";
    _topView.backgroundColor = navi_bar_bg_color;
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 35, 15)];
    lbl_return.text = @"返回";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 60, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
    
    NSUserDefaults * userdefault = [NSUserDefaults standardUserDefaults];
    
    if(![[userdefault objectForKey:@"Card_Number"] isEqualToString:@"1"])
    {
        [self p_alert];
    }
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
}

#pragma mark - 提示框
- (void )p_alert
{
    UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"还没有可提现的银行卡,请先添加一张支持提现的储蓄卡" preferredStyle:(UIAlertControllerStyleAlert)];
    [self presentViewController:alert animated:YES completion:^{
        
    }];
    
    UIAlertAction * action_Cancel = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
        [self.navigationController popViewControllerAnimated:YES];
        
    }];
    [alert addAction:action_Cancel];
    
    UIAlertAction * action_Ok = [UIAlertAction actionWithTitle:@"添加银行卡" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
        Add_RechargeCardViewController * add_RechargeCardViewController = [[Add_RechargeCardViewController alloc] init];
        [self showViewController:add_RechargeCardViewController sender:nil];
        
    }];
    [alert addAction:action_Ok];
}










@end
